/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package serversock;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 *
 * @author Ali Subhani
 */
public class ServerSock {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
     ServerSocket ss = new ServerSocket(9999);
     Socket sock = ss.accept();
     BufferedReader bdr= new BufferedReader(new InputStreamReader(sock.getInputStream()));
     String msg =bdr.readLine();
     System.out.println("Received message "+ msg);
     //Send Response to the Client
     if (msg!=null){
     PrintStream ps = new PrintStream(sock.getOutputStream());
     String str = "I have Received message"+msg;
     ps.println(str);
     }
     }
    
}
